<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title>房间批量导入</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" href="css/common.css">
<link href="js/select2/select2.min.css" type="text/css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="js/webuploader-0.1.5/webuploader.css" />
<script src="js/jquery-1.11.1.js"></script>
<script src="js/bootstrap2/js/bootstrap.min.js"></script>
<script src="js/select2/select2.min.js"></script>
<script type="text/javascript" src="js/form.js"></script>
<script type="text/javascript" src="js/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="js/sharefunction.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script>
<!-- 图片放大 -->
<script src="js/postbird-img-glass/postbird-img-glass.js"></script>
<style>
.webuploader-container {
	position: relative;
	top: 5px;
}
</style> 
<script type="text/javascript">
	$(function(){
		initWebUpload("filePicker_excelroom", "list_excelroom", "房间excel信息", "roomInfo_articleId", planStageSuccess, planStageErr);
	})
</script>
</head>
<body>
	<form action="roomInfo/excelAddRoomInfo" id="roomInfoExcelAdd" method="post"onsubmit="return false;">
		<input type="hidden" id="roomInfo_articleId">
		<div style="margin:20px 0px;">
			<table class="table">
					<tr>
						<!-- <td width="150" class="td-right">
							所属楼层：
						</td> -->
						<td width="150">选择文件：<div id='filePicker_excelroom' style="display: inline-block;">上传</div></td>
						<td style="text-align:left;">
							<!-- 附件上传 excel添加房间。。。--> <!-- 缩略图容器 -->
							<div id='list_excelroom'></div>
						</td>
					</tr>
					<tr>
						<td colspan='2'>
							<!-- <button class="btn btn-danger radius my-btn"
								onclick="saveRoomInfo(0)" type="button">提交</button> -->
							<button class="btn btn-danger radius my-btn"
								onclick="saveDocument()" type="button">保 存</button>
							<a class="btn btn-default radius" onclick="closeBtn()"> 取消 </a>
							<br />
						</td>
					</tr>
			</table>
		</div>
		<input type="hidden" name="fkBuildingUnit" id="fkBuildingUnit"value="">
	</form>
	<script type="text/javascript">
		function saveDocument(){
			var ss=$('#roomInfo_articleId').val();
			if(ss.length>99){
				layer.alert("只能选择一个Excel文件",{icon:7});
				return false;
			}
			//loading层
			layer.msg('处理中，请稍后...', {icon: 16});
			var fkBuildingUnit = parent.buildFloorId;//2017.12.04由单元id更改为楼层id
				var url="roomInfo/excelAddRoomInfo";
				jQuery.ajax({
				    type:"post",
				    async:false,
				    url:url,
			        dataType:"json",
			        data:{
			        	AccessoryCaList:ss,
			        	fkBuildingUnit:fkBuildingUnit
			        },
				    success:function(responseText){
				    	if (responseText.success) {
				    		if(responseText.msg.indexOf("房间号")!=-1){
								parent.layer.alert(responseText.msg);
								//重新点击父页面已被选择的元素，以达到刷新房间号的目的
								$("div.nav-floor ul.floor-list li[class='active']", parent.document).click();
								window.parent.updateRoom();
							}else{
								layer.msg(responseText.msg,{
									time: 2000
								},function(){
									//重新点击父页面已被选择的元素，以达到刷新房间号的目的
									$("div.nav-floor ul.floor-list li[class='active']", parent.document).click();
									window.parent.updateRoom();
								});
							}
						} else{
							layer.msg('保存失败！');
						}
				    }
		   		});
		}
		
		function closeBtn(){
			var $iframe=parent.$("#selectTab");
			$iframe.attr("src","");
		}
		//上传成功回调
		function planStageSuccess(file, response) {
			PostbirdImgGlass.init({
				domSelector : "td img",
				animation : true,
				myDocument : window.parent.parent.parent
			});
		}
		//上传失败回调
		function planStageErr(file, data) {
			//alert("上传失败回调");
		}
	</script>
</body>
</html>
